package org.bpms.util;

import java.text.SimpleDateFormat;

import org.beetl.core.Format;

/**
 * oracle时间转换
 * @author hupei
 *
 */
public class DateFormat implements Format{

	@Override
	public Object format(Object data, String pattern) {
		if (data == null)
            return null;
		if ( data.getClass().getName().equals("oracle.sql.TIMESTAMP")){
			SimpleDateFormat sdf = null;
			java.sql.Timestamp time = (java.sql.Timestamp)data;
            if (pattern == null)
            {
                    sdf = new SimpleDateFormat();
            }else{
            	sdf = new SimpleDateFormat(pattern);
            }
            return sdf.format(time);
		}
		else
        {
                throw new RuntimeException("Arg Error:Type should be Date");
        }
	}

}
